﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.Unity;
using PNProject.EF;
using PNProject.Core;

namespace PNProject
{
    public class IoC
    {
        private static IUnityContainer container;

        public static void Initialize()
        {
            container = new UnityContainer();
            container.RegisterType<IRepository<Banner>, BannerRepo>();
            container.RegisterType<IRepository<Support>, SupportRepo>();
            container.RegisterType<IRepository<XUser>, XUserRepo>();
            container.RegisterType<IRepository<Feedback>, FeedbackRepo>();
            container.RegisterType<IRepository<OneContent>, OneContentRepo>();
            container.RegisterType<IRepository<Link>, LinkRepo>();
            container.RegisterType<IRepository<News>, NewsRepo>();
            container.RegisterType<IRepository<Category>, CategoryRepo>();
            container.RegisterType<IRepository<Setting>, SettingRepo>();
            container.RegisterType<IRepository<TBEmail>, TBEmailRepo>();
            container.RegisterType<IRepository<Library>, LibraryRepo>();
            container.RegisterType<IRepository<Item>, ItemRepo>();
            container.RegisterType<IRepository<CMenu>, CMenuRepo>();
            container.RegisterType<IRepository<Product>, ProductRepo>();
            container.RegisterType<IRepository<LocationMap>, LocationRepo>();
            container.RegisterType<IRepository<Comment>, CommentRepo>();
            container.RegisterType<IRepository<LocationIp>, LocationIpRepo>();
            container.RegisterType<IRepository<UserTracking>, UserTrackingRepo>();
            container.RegisterType<IRepository<ProductIP>, ProductLocationIpRepo>();
        }

        public static T Resolve<T>()
        {
            return container.Resolve<T>();
        }

        public static void ShutDown()
        {
            container.Dispose();
        }
    }
}